package org.richin.regex.util;

import org.springframework.util.AntPathMatcher;

public class RegexUtils {
	private static final AntPathMatcher ANT_PATH_MATCHER = new AntPathMatcher();

	/**
     * ANT的路径匹配
     *
     * @param pattern
     * @param content
     * @return
     */
    public static boolean antPathMatch(String pattern, String content) {
            if (pattern == null) {
                    return false;
            }
            if ("*".equals(pattern)) {
                    return true;
            }
            return ANT_PATH_MATCHER.match(pattern, content);
    }

    /**
     * ANT的路径匹配
     *
     * @param patterns
     * @param content
     * @return
     */
    public static boolean antPathMatch(String[] patterns, String content) {
            if (patterns != null) {
                    for (int i = 0; i < patterns.length; i++) {
                            if (antPathMatch(patterns[i], content)) {
                                    return true;
                            }
                    }
            }
            return false;
    }
public static void main(String[] args) {
		//antPathMatch(content:encoded, content)
}
}
